package org.example.controller;


import org.example.domain.Result;
import org.example.domain.UtcItemRecord;
import org.example.service.IUtcItemRecordService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * recordController
 * 
 * @author coderfun
 * @date 2024-11-27
 */
@RestController
@RequestMapping("/system/record")
public class UtcItemRecordController
{
    @Autowired
    private IUtcItemRecordService utcItemRecordService;
    /**
     * 获取record详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:record:query')")
    @GetMapping(value = "/{itemId}")
    public Result getInfo(@PathVariable("itemId") Long itemId)
    {
        return Result.success(utcItemRecordService.selectUtcItemRecordByItemId(itemId));
    }

    /**
     * 新增record
     */
    @PreAuthorize("@ss.hasPermi('system:record:add')")
    @PostMapping
    public Result add(@RequestBody UtcItemRecord utcItemRecord)
    {
        return Result.success(utcItemRecordService.insertUtcItemRecord(utcItemRecord));
    }

    /**
     * 修改record
     */
    @PreAuthorize("@ss.hasPermi('system:record:edit')")
    @PutMapping
    public Result edit(@RequestBody UtcItemRecord utcItemRecord)
    {
        return Result.success(utcItemRecordService.updateUtcItemRecord(utcItemRecord));
    }

    /**
     * 删除record
     */
    @PreAuthorize("@ss.hasPermi('system:record:remove')")
	@DeleteMapping("/{itemIds}")
    public Result remove(@PathVariable Long[] itemIds)
    {
        return Result.success(utcItemRecordService.deleteUtcItemRecordByItemIds(itemIds));
    }
}
